<div class="row">
	<div class="col-md-12">
		<ol class="breadcrumb">
			<li>
				<a href="#" onclick="toHome()">
					主页
				</a>
			</li>
			<li>
				<a href="#" class="toList" onclick="toCounponList()">
					通兑卡列表
				</a>
			</li>
			<li class="active">
				查看批量绑定
			</li>
		</ol>
	</div>
</div>
<form role="form" class="form-horizontal">
	<div class="row page-cont">
		<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 cont-top">
			<div class="panel panel-white">
				<div class="panel-heading">
					<h4 class="panel-title">
						<span class="title-text">查看批量绑定</span>
					</h4>
					<div class="panel-tools">
						<div class="dropdown">
							<a data-toggle="dropdown" class="btn btn-xs dropdown-toggle btn-transparent-grey">
								<i class="fa fa-cog"></i>
							</a>
							<ul class="dropdown-menu dropdown-light pull-right" role="menu">
								<li>
									<a class="panel-collapse collapses" href="#"><i class="fa fa-angle-up"></i> <span>折叠</span> </a>
								</li>
								<li>
									<a class="panel-expand" href="#">
										<i class="fa fa-expand"></i> <span>全屏</span>
									</a>
								</li>
							</ul>
						</div>
						<a class="btn btn-xs btn-link panel-close" href="#">
							<i class="fa fa-times"></i>
						</a>
					</div>
				</div>
				<div class="panel-body table-body">
					<table class="table table-bordered table-hover">
						<thead>
							<tr>
								<th class="hidden-xs">卡号</th>
								<th class="hidden-xs">密码</th>
								<th class="hidden-xs">使用状态</th>
							</tr>
						</thead>
						<tbody>
							
						</tbody>
					</table>
				</div>				
				<!-- <div class="panel-body">
					<div class="form-group panel-cont">
					    <label class="col-sm-2 control-label">卡号</label>
					    <div class="col-sm-3">
					      <input type="text" readonly="readonly" class="form-control card-code" />
					    </div>							    
				  	</div>	
					<div class="form-group panel-cont">
					    <label class="col-sm-2 control-label">密码</label>
					    <div class="col-sm-3">
					      <input type="text" readonly="readonly" class="form-control card-pwd" />
					    </div>							    
				  	</div>	
					<div class="form-group panel-cont">
					    <label class="col-sm-2 control-label">使用状态</label>
					    <div class="col-sm-3">
					      <input type="text" readonly="readonly" class="form-control card-status" />
					    </div>							    
				  	</div>					  					  					
				</div> -->
			</div>
		</div>
	</div>
</form>
<script>
	/**********************************************变量**********************************************/
	var username = GetQueryString("username");     // 用户姓名
	var token = MXCookie.get("token",token);       // 登陆token

	/**********************************************函数**********************************************/
	// 获取列表
	function getList(){
		$("tbody").html("");
		$.ajax({
			url: localStorage.grobalUrl + "/discount/viewCardAndPass",
			type: "post",
			data:{
				username: username,
				token: token,  
				couponID: $(".pageAdd").attr("data-id")
			},
			success: function(data){
				console.log(data);
				if(data.errCode == "00000"){
					var str = '<tr align="center">'+
								'<td class="card-code"></td>'+
								'<td class="card-pwd"></td>'+
								'<td class="card-status"></td>'+
							'</tr>';
					if(data.errMsg.length == "0"){
						$("tbody").append("<tr><td align='center' colspan='3'>暂无数据</td></tr>");
					}
					for(var i = 0; i< data.errMsg.length; i++){
						$("tbody").append(str);
						var dataVal = data.errMsg[i];
						$(".card-code").eq(i).text(dataVal.codeNum);
						$(".card-pwd").eq(i).text(dataVal.code);
						if(dataVal.status == "NOT_USE"){
							$(".card-status").eq(i).text("未使用");
						}else{
							$(".card-status").eq(i).text("已使用");
						}					
					}
				}else if(data.errCode == "00001"){
					alert("此优惠券未被批量绑定");
				}else if(data.errCode == "00005"){
					tips("请重新登陆");
					setTimeout(function(){
						window.location.href = "login_login.html";
					},500);					
				}else{
					$("tbody").append("<tr><td align='center' colspan='3'>暂无数据</td></tr>");
				}
			},
			error: function(error){
				console.log(error);
			}
		});						
	}
	getList();	
	

</script>
